<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="__static__/admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="__static__/admin/css/select.css" rel="stylesheet" type="text/css" />
<!--<script type="text/javascript" src="__static__/admin/js/jquery.js"></script>-->
<script type="text/javascript" src="__static__/share/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="__static__/admin/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="__static__/admin/js/select-ui.min.js"></script>
 
<script type="text/javascript">
$(document).ready(function(e) {
    $(".select1").uedSelect({
		width : 345			  
	});
	$(".select2").uedSelect({
		width : 167  
	});
	$(".select3").uedSelect({
		width : 100
	});
});
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">系统设置</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    <div class="tools">
    
        <ul class="toolbar">
            <li onclick="deleteAllCommunity()"><span><img src="__static__/admin/images/t03.png" /></span>删除</li>
        </ul>
    </div>
    <div id="usual1" class="usual"> 
    
  	<div id="" class="tabson">
    
    
            <form method="get" action="{:url($val)}" >

            <ul class="seachform">
        
                <li>
                    <label>搜索用户名</label><input type="text" name="Uname" value="{$Uname}" class="scinput" />
                </li>               
                <li>
                    <label>发布时间</label><input name="StarAddTime" type="date" class="scinput" value="{$StarAddTime}"/>-<input name="EndAddTime" type="date" class="scinput" value="{$EndAddTime}"/>
                </li>
                <li><label>状态</label>  
                <div class="vocation">
                <select class="select3" name="State">
                    <option value="0">全部</option>
                    <option value="1" {if $State EQ 1} selected{/if}>已读</option>
                    <option value="3" {if $State EQ 3} selected{/if}>未读</option>
                    <option value="2" {if $State EQ 2} selected{/if}>待审核</option>
                </select>
                </div>
                </li>
                <li><label>&nbsp;</label><input type="submit" class="scbtn" value="查询"/></li>   
            </ul>
        </form>
    
    
    <table class="tablelist">
    	<thead>
    	<tr>
        <th><input name="checkboxs" type="checkbox" value=""/></th>
        <th>发布者<i class="sort"><img src="__static__/admin/images/px.gif" /></i></th>
        <th>发布时间</th>
        <th>状态</th>
        <th>留言内容</th>
        <th>更新状态</th>
        <th>操作</th>
        </tr>
        </thead>
        <tbody>
          {foreach $community_list as $v}
          <tr>
            <td><input name="checkbox" type="checkbox" value="{$v.id}" /></td>
            <td>{$v.User_id|getUserInfo}</td>
            <td>{:date('Y-m-d H:i:s',$v.Addtime)}</td>
            <td>{if $val EQ 'message'}{$v.State|getMessageToexamine}{else/}{$v.State|getFeedbackToexamine}{/if}</td>
            <td>{$v.Content}</td>
            <td>
                <select class="select3" onchange="toexamineCommunity({$v.id},this.value)">
                    <option value="1" {if $v.State EQ 1} selected{/if}>已读</option>
                    <option value="3" {if $v.State EQ 3} selected{/if}>未读</option>
                    <option value="2" {if $v.State EQ 2} selected{/if}>待审核</option>
                </select> 
            </td>
            <td>    
                <a href="javascript:;seerCommunityRply({$v.id})" class="tablelink">查看</a> 
                <a href="javascript:;editCommunityInfo({$v.id})" class="tablelink">回复</a>  
                <a href="javascript:;deleteCommunity({$v.id})" class="tablelink"> 删除</a>
            </td>
          </tr> 
          <tbody hidden id="Rply{$v.id}">
            {foreach $v.Rply as $k}
                <tr>
                    <td><input name="checkbox" type="checkbox" value="{$k.id}" /></td>
                    <td>{$k.User_id|getUserInfo}</td>
                    <td>{$k.Addtime}</td>
                    <td>{if $val EQ 'message'}{$k.State|getMessageToexamine}{else/}{$k.State|getFeedbackToexamine}{/if}</td>
                    <td>{:str_repeat('&nbsp;',$k.Level*2)}|-{$k.Content}</td>
                    <td>
                        <select class="select3" onchange="toexamineCommunity({$k.id},this.value)">
                            <option value="1" {if $k.State EQ 1} selected{/if}>已读</option>
                            <option value="3" {if $k.State EQ 3} selected{/if}>未读</option>
                            <option value="2" {if $k.State EQ 2} selected{/if}>待审核</option>
                        </select> 
                    </td>
                    <td>    
                        <a href="javascript:;seerCommunityRply({$v.id})" class="tablelink">查看</a> 
                        <a href="javascript:;editCommunityInfo({$v.id})" class="tablelink">回复</a>  
                        <a href="javascript:;deleteCommunity({$v.id})" class="tablelink"> 删除</a>
                    </td>
                </tr> 
            {/foreach}
        </tbody>
          {/foreach}
        </tbody>
    </table>
    
   
  
    
    </div>  
       
	</div>   
  </div>

     <div class="pagin">
    	<div class="message">共<i class="blue">{$pageListr->total()}</i>条记录，当前显示第&nbsp;<i class="blue">{$pageListr->currentPage()}&nbsp;</i>页</div>
        {$pageListr->render()}
    </div>
</body>
</html>
 
<script type="text/javascript"> 
    val = '{$val}';
    checkboxs = $('input[name="checkboxs"]');
    checkbox = $("input[name='checkbox']");
    function deleteCommunity(id){
        if(!confirm('确认删除此记录？')) return false;
        $.post('{:url("deleteCommunity")}',{id:id,val:val},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code == 1) window.location.reload();
        })
    }
    function deleteAllCommunity(){
        if(!confirm('是否删除所有选中的记录？')) return false;
         var ids=0;  
        checkbox.each(function() {  
            if ($(this).is(':checked')) {  
                ids += ","+$(this).val();  
            }  
        });  
       $.post('{:url("deleteCommunity")}',{id:ids,val:val},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code == 1 ) window.location.reload();
        })
    } 
    function toexamineCommunity(id,sta){
        $.post('{:url("toexamineCommunity")}',{id:id,sta:sta,val:val},function(res){
            console.log('返回数据',res)
            alert(res.msg)
            if(res.code) window.location.reload();
        })
    }
    function seerCommunityRply(id){
        $('#Rply'+id).fadeToggle(100);
        // $.post('{:url("seerCommunityRply")}',{id:id,val:val},function(res){
        //     console.log('返回数据',res)
        //     alert(res.msg)
        //     // alert(res.msg)
        //     if(res.code == 1){

        //     };
        // })
    }
    checkboxs.click(function(){
        if($(this).is(':checked')){
             checkbox.attr('checked',true);
        }else{
             checkbox.attr('checked',false);
        }
    })
    checkbox.click(function(){
        var ck = $("input[name='checkbox']").length;
        var cm = $("input[type='checkbox']:checked").length;
        $(this).each(function(){
              if(!$(this).is(':checked') || ck != cm){
                  checkboxs.attr('checked',false);
              }else{
                  checkboxs.attr('checked',true);
            }
          }
        )
    })

	</script>
